package tech.aistar.controller.center;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import tech.aistar.entity.CodeStatus;
import tech.aistar.entity.RealName;
import tech.aistar.entity.Result;
import tech.aistar.entity.User;
import tech.aistar.mapper.client.UserMapper;
import tech.aistar.service.client.IUserService;
import tech.aistar.vo.PasswordVo;
import tech.aistar.vo.Really;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * Created by 23827 on 2019/10/4.
 */
@Controller
@RequestMapping("/password")
public class CenterPasswordController {
    @Autowired
    private IUserService iUserService;
    @RequestMapping("/list")
    public String Update(){
        return "user/centerPassword";
    }

    @RequestMapping("/update")
    @ResponseBody
    public Result update(@RequestBody PasswordVo passwordVo, HttpSession session){
        System.out.println(passwordVo);
        Integer id = (Integer) session.getAttribute("userId");
        System.out.println(id);
        User user = new User();
        user.setId(id);
        user.setPassword(passwordVo.getNewPassword());
        iUserService.updateById(user);
        return new Result(CodeStatus.OK,true,"修改成功");

    }

}
